package com.xiaoshuidi.cloud.module.guanwang.controller.app.dict;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.guanwang.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.system.api.dict.DictDataApi;
import com.xiaoshuidi.cloud.module.system.api.dict.dto.DictDataRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;

@RestController
@RequestMapping(ApiConstants.NAME + "/dict-data")
public class DictDataController {

    @Resource
    private DictDataApi dictDataApi;

    @PermitAll
    @GetMapping({"/get-dict-data"})
    @Operation(
            summary = "获得字典数据列表"
    )
    @Parameters({@Parameter(
            name = "dictType",
            description = "字典类型",
            example = "SEX",
            required = true
    )})
    CommonResult<List<DictDataRespDTO>> getDictDataByType(@RequestParam("dictType") String dictType) {
        return dictDataApi.getDictDataByType(dictType);
    }
}
